Skip to content

Sphere grid memory mapping #287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 1, 2022
Merged

Conversation

orkaboy
Copy link
Collaborator

@orkaboy orkaboy commented Nov 29, 2022

Implementation of #180

A small API to read out the state of the sphere grid. Also contains an example app that uses the API.

print(f"Node at idx=123 is {node_123}")

last_node = 0
while True:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want this to actually run forever? Because this doesn't have a break or a return.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment below.

from memory.sphere_grid import SphereNodeType, sphere_grid

# Wait for memory to finish loading
while not memory.main.start():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably worth wrapping most of this stuff in a function. The act of importing this file would do bad things right now. Lol.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment clarifying that this file is not meant to be integrated into the TAS, only serve as an example on how to use the API.

"""This returns a one byte bitfield, where each bit indicates that a character has activated this node."""
return read_val(self.offset + self._ACTIVATED_BY_OFFSET, 1)

def is_activated_by(self, character_id: int) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we lean into the new world here. Instead of passing in character_id: int, I'd rather see character: Player, then we either implement the bitwise operator for the class or grab the id off the player object further down.

Thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined to agree with you. I'll make some tweaks and test.

@coderwilson coderwilson merged commit 259934b into coderwilson:main Dec 1, 2022
@orkaboy orkaboy deleted the dev/sphere_grid branch December 1, 2022 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants